#include "jsapi.h"
#include "js-engine.h"
#include "desktopClasses.h"
#include "mainview-parser.h"

static JSBool object_new(JSContext *cx, JSObject *obj, uintN argc, jsval *args, jsval *rval);

static JSFunctionSpec object_methods[] = {
    {NULL, NULL, 0, 0, 0}
};

JSClass objectClass =
    { "object", JSCLASS_HAS_PRIVATE,
      JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
      JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
      JSCLASS_NO_OPTIONAL_MEMBERS
    };

struct property_parser object_parser[] = {
    /* from basicElement */
    {"cursor", set_property_string_value},
    {"dropTarget", set_property_boolean_value},
    {"enabled", set_property_boolean_value},
    {"height", set_property_integer_value},
    {"hitTest", set_property_string_value},
    {"mask", set_property_string_value},
    {"name", set_property_string_value},
    {"offsetHeight", set_property_integer_value},
    {"offsetWidth", set_property_integer_value},
    {"offsetX", set_property_integer_value},
    {"offsetY", set_property_integer_value},
    {"opacity", set_property_integer_value},
    {"pinX", set_property_integer_value},
    {"pinY", set_property_integer_value},
    {"rotation", set_property_float_value},
    {"tagName", set_property_string_value},
    {"tooltip", set_property_string_value},
    {"width", set_property_integer_value},
    {"visible", set_property_boolean_value},
    {"x", set_property_integer_value},
    {"y", set_property_integer_value},
		
    {"classId", set_property_string_value},
    {"object", set_property_stub},
    {"wmpServiceType", set_property_stub},
    {"wmpSkin", set_property_string_value},
    {NULL, NULL},
};

static JSBool object_new(JSContext *cx, JSObject *obj, uintN argc, jsval *args, jsval *rval)
{
    g_message("object new");
    return JS_TRUE;
}

JSObject *objectClass_init(js_engine *engine, JSObject *parent)
{
    JSObject *proto = NULL;
    proto = JS_InitClass(engine->cx, engine->glob, parent,
			 &objectClass, object_new,
			 0,NULL,NULL,NULL,NULL);
    g_return_val_if_fail(proto, FALSE);
    g_return_val_if_fail(JS_DefineFunctions(engine->cx, proto, object_methods), FALSE);
    return proto;
}
